import 'package:flutter/material.dart';
import 'package:flutter_custom_bottom_tab_bar/tabbar.dart';
import 'package:flutter_custom_bottom_tab_bar/eachtab.dart';
import 'dart:ui';
import '../../base/Constant.dart';
import 'AllOrderPage.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class OrderPage extends StatefulWidget {
  int index;
  OrderPage({Key key, this.index}) : super(key: key);
  @override
  State<StatefulWidget> createState() {
    return new OrderView();
  }
}

class OrderView extends State<OrderPage> with SingleTickerProviderStateMixin {
  TabController _tabController;
  String badgeNo1;

//   订单状态 
// 1待付款 
// 2已付款、待发货 
// 3已发货、待确认收货
// 4已确认收货、待评价 
// 5已完成 
// 6退换货

  var titles = ['全部','待付款', '待发货', '待收货','待评价','已完成', '申请退货','同意退货','拒绝退货', '已退货'];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController =
        new TabController(vsync: this, initialIndex: widget.index, length: titles.length);
    badgeNo1 = '12';
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    final width = size.width;
    return Scaffold(
      appBar: AppBar(
        flexibleSpace: Container(
                decoration: BoxDecoration(
                    color:Color.fromARGB(255, 255, 140, 16),
                ),
              ),
          title: Text(
            '我的订单',
            style: TextStyle(
                color: white,
                fontSize: ScreenUtil.getInstance().setSp(BIG_FONT_SIZE)),
          ),
          elevation: 0.5,
          backgroundColor: white,
          iconTheme: new IconThemeData(color:white),
          brightness: Brightness.light,
          bottom: TabContainer(
              // alignment: Alignment.center,
              color: Colors.white,
              child: Stack(
                overflow: Overflow.clip,
                children: <Widget>[
                  Container(
                    child: new TabBar(
                      isScrollable: true,
                      controller: _tabController,
                      indicatorColor: mainColor,
                      labelColor: Colors.red,
                      labelPadding: EdgeInsets.all(0),
                      unselectedLabelColor: Colors.black,
                      tabs: <Widget>[
                        EachTab(
                          text: titles[0],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        EachTab(
                          text: titles[1],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        EachTab(
                          text: titles[2],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        new EachTab(
                          text: titles[3],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        new EachTab(
                          text: titles[4],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        new EachTab(
                          text: titles[5],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                         new EachTab(
                          text: titles[6],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        new EachTab(
                          text: titles[7],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        new EachTab(
                          text: titles[8],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                        new EachTab(
                          text: titles[9],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE)),
                        ),
                      ],
                    ),
                  ),
                ],
              ))),
      body: TabBarView(controller: _tabController, children: <Widget>[
        Center(
            child: new AllOrderPage(
          type: 0,
        )),
        Center(
            child: new AllOrderPage(
          type: 1,
        )),
        Center(
            child: AllOrderPage(
          type: 2,
        )),
        Center(
            child: AllOrderPage(
          type: 3,
        )),
        Center(
            child: AllOrderPage(
          type: 4,
        )),
         Center(
            child: AllOrderPage(
          type: 5,
        )),
        Center(
            child: AllOrderPage(
          type: 6,
        )),
         Center(
            child: AllOrderPage(
          type: 7,
        )),
         Center(
            child: AllOrderPage(
          type: 8,
        )),
         Center(
            child: AllOrderPage(
          type: 9,
        )),
        // Center(child: AllOrderPage(type: 9,)),
      ]),
    );
  }
}
